using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;

namespace NAVA.MTSLibrary
{
    public class XmlLocalResolver : XmlUrlResolver
    {
        Uri _baseUri;

        public Uri BaseURI
        {
            get { return _baseUri; }
            set { _baseUri = value; }
        }

        public XmlLocalResolver(string prmstrLocalPath)
        {
            BaseURI = new Uri(prmstrLocalPath);
        }

        public override Uri ResolveUri(Uri baseUri, string relativeUri)
        {
            //if (relativeUri.StartsWith(@"\"))
            //    relativeUri = relativeUri.Substring(1);
            //if (relativeUri.IndexOf(@"file:///") == -1)
            //{   // Not a fully qualified file reference
            //    Uri uri = new Uri(@"file://" + BaseURI.AbsolutePath + relativeUri);
            //    return uri;
            //}
            //else
            //{   // Fully qualified file reference, leave it alone
            //    Uri uri = new Uri(relativeUri);
            //    return uri;
            //}

            Uri uri = new Uri("file://" + BaseURI.AbsolutePath + relativeUri);

            return uri;

        }
    }
}
